﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace EP2_Gameserver
{
    public static class Config
    {

        public static IPAddress GameServerIP;
        public static int GameServerPort;

        public static int[] newKnight = new int[24];
        public static int[] newTitan = new int[24];
        public static int[] newHealer = new int[24];
        public static int[] newMage = new int[24];
        public static int[] newRogue = new int[24];
        public static int[] newSorcerer = new int[24];
        public static int[] newNightShadow = new int[24];

        public static int[][] newChar = new int[10][];

        public static void Read()
        {
            try
            {
                TextReader tr = new StreamReader("GameServer.cfg");

                string line;
                while ((line = tr.ReadLine()) != null)
                {
                    if (line.Contains("#") || line.Length == 0)
                    {
                    }
                    else
                    {
                        string[] values = line.Split('=');
                        foreach (string v in values)
                        {
                            if (values[0] == "IP") GameServerIP = IPAddress.Parse(values[1]);
                            if (values[0] == "PORT") GameServerPort = Convert.ToInt32(values[1]);
                            if (values[0] == "SQL_HOST") mySQL.host = values[1];
                            if (values[0] == "SQL_DBASE") mySQL.database = values[1];
                            if (values[0] == "SQL_USER") mySQL.user = values[1];
                            if (values[0] == "SQL_PASSWORD") mySQL.password = values[1];


                        }

                    }
                }

                LogScreen.Info("Global Config file Loaded");
            }
            catch (Exception e)
            {
                LogScreen.Error("Global Config file Error : " + e);
            }

        }
        public static void newCharacter()
        {
            newChar[0] = new int[24];
            newChar[1] = new int[24];
            newChar[2] = new int[24];
            newChar[3] = new int[24];
            newChar[4] = new int[24];
            newChar[5] = new int[24];
            newChar[6] = new int[24];
            newChar[7] = new int[24];

            try
            {
                TextReader tr = new StreamReader("NewCharacter.cfg");

                string line;
                while ((line = tr.ReadLine()) != null)
                {
                    if (line.Contains("#") || line.Length == 0)
                    {
                    }
                    else
                    {
                        string[] values = line.Split('=');
                        foreach (string v in values)
                        {
                            int data = Convert.ToInt32(values[1]);

                            if (values[0] == "NI_HP") newChar[1][1] = data;
                            if (values[0] == "NI_MP") newChar[1][2] = data;
                            if (values[0] == "NI_LEVEL") newChar[1][3] = data;
                            if (values[0] == "NI_EQ_HELM_ID") newChar[1][4] = data;
                            if (values[0] == "NI_EQ_HELM_PLUS") newChar[1][5] = data;
                            if (values[0] == "NI_EQ_SHIRT_ID") newChar[1][6] = data;
                            if (values[0] == "NI_EQ_SHIRT_PLUS") newChar[1][7] = data;
                            if (values[0] == "NI_EQ_PANTS_ID") newChar[1][8] = data;
                            if (values[0] == "NI_EQ_PANTS_PLUS") newChar[1][9] = data;
                            if (values[0] == "NI_EQ_GLOVES_ID") newChar[1][10] = data;
                            if (values[0] == "NI_EQ_GLOVES_PLUS") newChar[1][11] = data;
                            if (values[0] == "NI_EQ_BOOTS_ID") newChar[1][12] = data;
                            if (values[0] == "NI_EQ_BOOTS_PLUS") newChar[1][13] = data;
                            if (values[0] == "NI_EQ_WEAPON_ID") newChar[1][14] = data;
                            if (values[0] == "NI_EQ_WEAPON_PLUS") newChar[1][15] = data;
                            if (values[0] == "NI_EQ_SHIELD_ID") newChar[1][16] = data;
                            if (values[0] == "NI_EQ_SHIELD_PLUS") newChar[1][17] = data;
                            if (values[0] == "NI_EQ_WING_ID") newChar[1][18] = data;
                            if (values[0] == "NI_EQ_WING_PLUS") newChar[1][19] = data;
                            if (values[0] == "NI_STR") newChar[1][20] = data;
                            if (values[0] == "NI_DEX") newChar[1][21] = data;
                            if (values[0] == "NI_INT") newChar[1][22] = data;
                            if (values[0] == "NI_CON") newChar[1][23] = data;
                            if (values[0] == "TI_HP") newChar[0][1] = data;
                            if (values[0] == "TI_MP") newChar[0][2] = data;
                            if (values[0] == "TI_LEVEL") newChar[0][3] = data;
                            if (values[0] == "TI_EQ_HELM_ID") newChar[0][4] = data;
                            if (values[0] == "TI_EQ_HELM_PLUS") newChar[0][5] = data;
                            if (values[0] == "TI_EQ_SHIRT_ID") newChar[0][6] = data;
                            if (values[0] == "TI_EQ_SHIRT_PLUS") newChar[0][7] = data;
                            if (values[0] == "TI_EQ_PANTS_ID") newChar[0][8] = data;
                            if (values[0] == "TI_EQ_PANTS_PLUS") newChar[0][9] = data;
                            if (values[0] == "TI_EQ_GLOVES_ID") newChar[0][10] = data;
                            if (values[0] == "TI_EQ_GLOVES_PLUS") newChar[0][11] = data;
                            if (values[0] == "TI_EQ_BOOTS_ID") newChar[0][12] = data;
                            if (values[0] == "TI_EQ_BOOTS_PLUS") newChar[0][13] = data;
                            if (values[0] == "TI_EQ_WEAPON_ID") newChar[0][14] = data;
                            if (values[0] == "TI_EQ_WEAPON_PLUS") newChar[0][15] = data;
                            if (values[0] == "TI_EQ_SHIELD_ID") newChar[0][16] = data;
                            if (values[0] == "TI_EQ_SHIELD_PLUS") newChar[0][17] = data;
                            if (values[0] == "TI_EQ_WING_ID") newChar[0][18] = data;
                            if (values[0] == "TI_EQ_WING_PLUS") newChar[0][19] = data;
                            if (values[0] == "TI_STR") newChar[0][20] = data;
                            if (values[0] == "TI_DEX") newChar[0][21] = data;
                            if (values[0] == "TI_INT") newChar[0][22] = data;
                            if (values[0] == "TI_CON") newChar[0][23] = data;
                            if (values[0] == "MA_HP") newChar[3][1] = data;
                            if (values[0] == "MA_MP") newChar[3][2] = data;
                            if (values[0] == "MA_LEVEL") newChar[3][3] = data;
                            if (values[0] == "MA_EQ_HELM_ID") newChar[3][4] = data;
                            if (values[0] == "MA_EQ_HELM_PLUS") newChar[3][5] = data;
                            if (values[0] == "MA_EQ_SHIRT_ID") newChar[3][6] = data;
                            if (values[0] == "MA_EQ_SHIRT_PLUS") newChar[3][7] = data;
                            if (values[0] == "MA_EQ_PANTS_ID") newChar[3][8] = data;
                            if (values[0] == "MA_EQ_PANTS_PLUS") newChar[3][9] = data;
                            if (values[0] == "MA_EQ_GLOVES_ID") newChar[3][10] = data;
                            if (values[0] == "MA_EQ_GLOVES_PLUS") newChar[3][11] = data;
                            if (values[0] == "MA_EQ_BOOTS_ID") newChar[3][12] = data;
                            if (values[0] == "MA_EQ_BOOTS_PLUS") newChar[3][13] = data;
                            if (values[0] == "MA_EQ_WEAPON_ID") newChar[3][14] = data;
                            if (values[0] == "MA_EQ_WEAPON_PLUS") newChar[3][15] = data;
                            if (values[0] == "MA_EQ_SHIELD_ID") newChar[3][16] = data;
                            if (values[0] == "MA_EQ_SHIELD_PLUS") newChar[3][17] = data;
                            if (values[0] == "MA_EQ_WING_ID") newChar[3][18] = data;
                            if (values[0] == "MA_EQ_WING_PLUS") newChar[3][19] = data;
                            if (values[0] == "MA_STR") newChar[3][20] = data;
                            if (values[0] == "MA_DEX") newChar[3][21] = data;
                            if (values[0] == "MA_INT") newChar[3][22] = data;
                            if (values[0] == "MA_CON") newChar[3][23] = data;
                            if (values[0] == "HW_HP") newChar[2][1] = data;
                            if (values[0] == "HW_MP") newChar[2][2] = data;
                            if (values[0] == "HW_LEVEL") newChar[2][3] = data;
                            if (values[0] == "HW_EQ_HELM_ID") newChar[2][4] = data;
                            if (values[0] == "HW_EQ_HELM_PLUS") newChar[2][5] = data;
                            if (values[0] == "HW_EQ_SHIRT_ID") newChar[2][6] = data;
                            if (values[0] == "HW_EQ_SHIRT_PLUS") newChar[2][7] = data;
                            if (values[0] == "HW_EQ_PANTS_ID") newChar[2][8] = data;
                            if (values[0] == "HW_EQ_PANTS_PLUS") newChar[2][9] = data;
                            if (values[0] == "HW_EQ_GLOVES_ID") newChar[2][10] = data;
                            if (values[0] == "HW_EQ_GLOVES_PLUS") newChar[2][11] = data;
                            if (values[0] == "HW_EQ_BOOTS_ID") newChar[2][12] = data;
                            if (values[0] == "HW_EQ_BOOTS_PLUS") newChar[2][13] = data;
                            if (values[0] == "HW_EQ_WEAPON_ID") newChar[2][14] = data;
                            if (values[0] == "HW_EQ_WEAPON_PLUS") newChar[2][15] = data;
                            if (values[0] == "HW_EQ_SHIELD_ID") newChar[2][16] = data;
                            if (values[0] == "HW_EQ_SHIELD_PLUS") newChar[2][17] = data;
                            if (values[0] == "HW_EQ_WING_ID") newChar[2][18] = data;
                            if (values[0] == "HW_EQ_WING_PLUS") newChar[2][19] = data;
                            if (values[0] == "HW_STR") newChar[2][20] = data;
                            if (values[0] == "HW_DEX") newChar[2][21] = data;
                            if (values[0] == "HW_INT") newChar[2][22] = data;
                            if (values[0] == "HW_CON") newChar[2][23] = data;
                            if (values[0] == "RO_HP") newChar[4][1] = data;
                            if (values[0] == "RO_MP") newChar[4][2] = data;
                            if (values[0] == "RO_LEVEL") newChar[4][3] = data;
                            if (values[0] == "RO_EQ_HELM_ID") newChar[4][4] = data;
                            if (values[0] == "RO_EQ_HELM_PLUS") newChar[4][5] = data;
                            if (values[0] == "RO_EQ_SHIRT_ID") newChar[4][6] = data;
                            if (values[0] == "RO_EQ_SHIRT_PLUS") newChar[4][7] = data;
                            if (values[0] == "RO_EQ_PANTS_ID") newChar[4][8] = data;
                            if (values[0] == "RO_EQ_PANTS_PLUS") newChar[4][9] = data;
                            if (values[0] == "RO_EQ_GLOVES_ID") newChar[4][10] = data;
                            if (values[0] == "RO_EQ_GLOVES_PLUS") newChar[4][11] = data;
                            if (values[0] == "RO_EQ_BOOTS_ID") newChar[4][12] = data;
                            if (values[0] == "RO_EQ_BOOTS_PLUS") newChar[4][13] = data;
                            if (values[0] == "RO_EQ_WEAPON_ID") newChar[4][14] = data;
                            if (values[0] == "RO_EQ_WEAPON_PLUS") newChar[4][15] = data;
                            if (values[0] == "RO_EQ_SHIELD_ID") newChar[4][16] = data;
                            if (values[0] == "RO_EQ_SHIELD_PLUS") newChar[4][17] = data;
                            if (values[0] == "RO_EQ_WING_ID") newChar[4][18] = data;
                            if (values[0] == "RO_EQ_WING_PLUS") newChar[4][19] = data;
                            if (values[0] == "RO_STR") newChar[4][20] = data;
                            if (values[0] == "RO_DEX") newChar[4][21] = data;
                            if (values[0] == "RO_INT") newChar[4][22] = data;
                            if (values[0] == "RO_CON") newChar[4][23] = data;
                            if (values[0] == "SO_HP") newChar[5][1] = data;
                            if (values[0] == "SO_MP") newChar[5][2] = data;
                            if (values[0] == "SO_LEVEL") newChar[5][3] = data;
                            if (values[0] == "SO_EQ_HELM_ID") newChar[6][4] = data;
                            if (values[0] == "SO_EQ_HELM_PLUS") newChar[6][5] = data;
                            if (values[0] == "SO_EQ_SHIRT_ID") newChar[6][6] = data;
                            if (values[0] == "SO_EQ_SHIRT_PLUS") newChar[6][7] = data;
                            if (values[0] == "SO_EQ_PANTS_ID") newChar[6][8] = data;
                            if (values[0] == "SO_EQ_PANTS_PLUS") newChar[6][9] = data;
                            if (values[0] == "SO_EQ_GLOVES_ID") newChar[6][10] = data;
                            if (values[0] == "SO_EQ_GLOVES_PLUS") newChar[6][11] = data;
                            if (values[0] == "SO_EQ_BOOTS_ID") newChar[6][12] = data;
                            if (values[0] == "SO_EQ_BOOTS_PLUS") newChar[6][13] = data;
                            if (values[0] == "SO_EQ_WEAPON_ID") newChar[6][14] = data;
                            if (values[0] == "SO_EQ_WEAPON_PLUS") newChar[6][15] = data;
                            if (values[0] == "SO_EQ_SHIELD_ID") newChar[6][16] = data;
                            if (values[0] == "SO_EQ_SHIELD_PLUS") newChar[6][17] = data;
                            if (values[0] == "SO_EQ_WING_ID") newChar[6][18] = data;
                            if (values[0] == "SO_EQ_WING_PLUS") newChar[6][19] = data;
                            if (values[0] == "SO_STR") newChar[6][20] = data;
                            if (values[0] == "SO_DEX") newChar[6][21] = data;
                            if (values[0] == "SO_INT") newChar[6][22] = data;
                            if (values[0] == "SO_CON") newChar[6][23] = data;
                            if (values[0] == "NS_HP") newChar[7][1] = data;
                            if (values[0] == "NS_MP") newChar[7][2] = data;
                            if (values[0] == "NS_LEVEL") newChar[7][3] = data;
                            if (values[0] == "NS_EQ_HELM_ID") newChar[7][4] = data;
                            if (values[0] == "NS_EQ_HELM_PLUS") newChar[7][5] = data;
                            if (values[0] == "NS_EQ_SHIRT_ID") newChar[7][6] = data;
                            if (values[0] == "NS_EQ_SHIRT_PLUS") newChar[7][7] = data;
                            if (values[0] == "NS_EQ_PANTS_ID") newChar[7][8] = data;
                            if (values[0] == "NS_EQ_PANTS_PLUS") newChar[7][9] = data;
                            if (values[0] == "NS_EQ_GLOVES_ID") newChar[7][10] = data;
                            if (values[0] == "NS_EQ_GLOVES_PLUS") newChar[7][11] = data;
                            if (values[0] == "NS_EQ_BOOTS_ID") newChar[7][12] = data;
                            if (values[0] == "NS_EQ_BOOTS_PLUS") newChar[7][13] = data;
                            if (values[0] == "NS_EQ_WEAPON_ID") newChar[7][14] = data;
                            if (values[0] == "NS_EQ_WEAPON_PLUS") newChar[7][15] = data;
                            if (values[0] == "NS_EQ_SHIELD_ID") newChar[7][16] = data;
                            if (values[0] == "NS_EQ_SHIELD_PLUS") newChar[7][17] = data;
                            if (values[0] == "NS_EQ_WING_ID") newChar[7][18] = data;
                            if (values[0] == "NS_EQ_WING_PLUS") newChar[7][19] = data;
                            if (values[0] == "NS_STR") newChar[7][20] = data;
                            if (values[0] == "NS_DEX") newChar[7][21] = data;
                            if (values[0] == "NS_INT") newChar[7][22] = data;
                            if (values[0] == "NS_CON") newChar[7][23] = data;


                        }

                    }
                }

                LogScreen.Info("New Character Config Loaded");
            }
            catch (Exception e)
            {
                LogScreen.Error("New Character Config Error : " + e);
            }

        }
    }
}
